package validationTestSuite.tests
{
	import com.google.code.flexmetavalidator.metavalidation.MetaValidator;
	
	import org.flexunit.Assert;
	import org.flexunit.asserts.assertFalse;
	import org.flexunit.asserts.assertTrue;
	
	import validationTestSuite.tests.vo.IsNumericObject;
	
	
	public class IsNumericTest extends MetaValidatorTest
	{
		public function IsNumericTest()
		{
			super();
		}
		
		[Test]
		public function testString():void
		{
			var object : IsNumericObject = new IsNumericObject();
			
			object.varString = null;
			var testResult : Boolean = validator.validate(object);
			assertFalse(testResult);
			
			object.varString = "10";
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			object.varString = "ABCD";
			testResult = validator.validate(object);
			assertFalse(testResult);
			
			object.varString = "0";
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			for each (var errStr : String in validator.errors) {trace(errStr)}
		}
		
		[Test]
		public function testNumber():void
		{
			var object : IsNumericObject = new IsNumericObject();
			object.varNumber = 0;
			var testResult : Boolean = validator.validate(object);
			assertTrue(testResult);
			
			object.varNumber = 10;
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			object.varNumber = NaN;
			testResult = validator.validate(object);
			assertFalse(testResult);
			
			object.varNumber = Infinity;
			testResult = validator.validate(object);
			assertTrue(testResult);
						
			for each (var errStr : String in validator.errors) {trace(errStr)}
		}
		
		[Test]
		public function testObject():void
		{
			var object : IsNumericObject = new IsNumericObject();
			object.varObject = null
			var testResult : Boolean = validator.validate(object);
			assertFalse(testResult);
			
			object.varObject = new Object();
			testResult = validator.validate(object);
			assertFalse(testResult);
			
			object.varObject = "ABCD";
			testResult = validator.validate(object);
			assertFalse(testResult);
			
			object.varObject = "12";
			testResult = validator.validate(object);
			assertTrue(testResult);
			
			object.varObject = 12;
			testResult = validator.validate(object);
			assertTrue(testResult);
						
			for each (var errStr : String in validator.errors) {trace(errStr)}
		}
				
		[Test]
		public function testGetter():void
		{
			var object : IsNumericObject = new IsNumericObject();
			object.getObject = 12;
			
			var testResult : Boolean = validator.validate(object);
			assertTrue(testResult);
			for each (var errStr : String in validator.errors) {trace(errStr)}
		}
		
	}
}